package top.laoshuzi.designpatterns.base.created.abstract_factory;

/**
 * 工厂管理类
 */
public class FactoryManager {

    public static final int TYPE_FACTORY_A = 1;
    public static final int TYPE_FACTORY_B = 2;

    public static Factory createFactory(int factoryType) {
        Factory factory = null;
        switch (factoryType) {
            case 1:
                factory = new FactoryA();
                break;
            case 2:
                factory = new FactoryB();
                break;
        }
        if (factory == null)
            throw new NullPointerException("无效工厂类型");
        return factory;
    }
}
